package com.sojpt.boot.controller.business.validator;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
import com.sojpt.model.LkyClass;


public class LkyClassUpdateValidator extends Validator {

    @Override
    protected void validate(Controller c) {

        LkyClass lkyClass = c.getModel(LkyClass.class, "lkyClass");

        if(lkyClass.get("name") != null)
            validateString("lkyClass.name", 0, 20, "msg", "班级名称 最多20个字符");
        validateRequired("lkyClass.name", "msg", "请输入班级名称");
        if(lkyClass.get("class_number") != null)
            validateString("lkyClass.class_number", 0, 20, "msg", "班级编号 最多20个字符");
        validateRequired("lkyClass.class_number", "msg", "请输入班级编号");
        if(lkyClass.get("mid") != null)
            validateString("lkyClass.mid", 0, 32, "msg", "专业id 最多32个字符");
        validateRequired("lkyClass.class_number", "msg", "专业id");
    }

    @Override
    protected void handleError(Controller c) {
        c.renderJson();
    }
}